package com.zq.assistant.func.okhttp.upload;

import com.squareup.okhttp.Callback;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.zq.assistant.func.okhttp.FileTransferListener;

import java.io.IOException;

/**
 * Created by zhangqiang on 17-6-7.
 */

public class FileUploadCallback implements Callback {

    private FileTransferListener fileTransferListener;

    public FileUploadCallback(FileTransferListener fileTransferListener) {
        this.fileTransferListener = fileTransferListener;
    }

    @Override
    public void onFailure(Request request, IOException e) {

        if(fileTransferListener != null){
            fileTransferListener.onFinish(request.urlString());
        }
    }

    @Override
    public void onResponse(Response response) {

        if(fileTransferListener != null){
            fileTransferListener.onFinish(response.request().urlString());
        }
    }
}
